package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

/**
 * @WebServlet注解：定位当前类为一个servlet程序
 * name属性：定义servlet名字 整个web应用唯一
 * value：定义servlet的访问路径
 * */
//路径    http://localhost:8080/MallTest/date/now
@WebServlet(name = "firstServlet", value = "/date/now")
public class FirstServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取系统的时间
        Date date = new Date();
        //获取相应的输出流
        resp.getWriter().println(date);
        resp.flushBuffer();
    }
}
